<script type="text/javascript" src="javascript/ajax/prototype.js"></script>
<script type="text/javascript" src="javascript/ajax/scriptaculous.js" ></script>
<script type="text/javascript" src="javascript/ajax/effects.js" ></script>
<script type="text/javascript" src="javascript/ajax/scriptaculous.js" ></script>

<!--////////////////////////////////////////Started Map//////////////////////////////-->
<script src="http://maps.google.com/maps?file=api&amp;v=2&amp;key=AIzaSyAUNoBX23zRuBjYg4WIWLLCN_Rprj67mcM"
  type="text/javascript"></script>

<script type="text/javascript" src="modules/iCarrent/pnjavascripts/InnoGoogleMap.js"></script>
<script type="text/javascript">
Event.observe( window, 'load', load );
Event.observe( window, 'unload', GUnload );
 function load() {
      if (GBrowserIsCompatible()) {
        //alert('load');
        var map = new GMap2(document.getElementById("map"));
        map.addControl(new GLargeMapControl());
        map.addControl(new GMapTypeControl());
        //alert('addControl');
        var center = new GLatLng(
		<!--[if empty($form.latitude)]-->
			<!--[13.744721008725115]-->
		<!--[else]-->
			<!--[$form.latitude]-->
		<!--[/if]-->
		,<!--[if empty($form.longitude)]-->
			<!--[100.50018310546875]-->
		<!--[else]-->
			<!--[$form.longitude]-->
		<!--[/if]-->
		);

    <!--[if empty($form.longitude)]-->
			map.setCenter(center, 6);
		<!--[else]-->
			map.setCenter(center, 13);
		<!--[/if]-->
        //alert('setCenter');
        map.openInfoWindow(map.getCenter(),document.createTextNode("ลากจุดนี้ไปยังที่ตั้งของคุณ"));

        var marker = new GMarker(center, {draggable: true});
        map.addOverlay(marker);

        document.getElementById("form[latitude]").value = center.lat();
        document.getElementById("form[longitude]").value = center.lng();
        //alert('addOverlay');
        GEvent.addListener(marker, "dragend", function() {
            var point =marker.getPoint();
            map.panTo(point);

            document.getElementById("form[latitude]").value = point.lat();
            document.getElementById("form[longitude]").value = point.lng();

        });
      } //end if
    }//end load
</script>
<!--////////////////////////////////////////End Map//////////////////////////////-->


<script type="text/javascript">

function getDistrict(obj){
  var div_district = document.getElementById('district_container');
  var province_id = document.getElementById('form_province_id_').value;

  if (province_id != 0)
  {
    var url = "index.php?module=iCarrent&type=ajax&func=list&ctrl=District&province_id="+province_id+""+ genSession() ;
    div_district.innerHTML ="Loading...";
    new Ajax.Request(url, {
    method:'get',
    onSuccess: function(transport){
      var result = transport.responseText;
      div_district.innerHTML= result;
    }
    });
  }else{
    div_district.innerHTML ="<FONT size='2' COLOR='#FF0000'>Plese select Category....</FONT>";
    new Ajax.Request(url, {
    method:'get',
    onSuccess: function(transport){
    var result = transport.responseText;
    div_district.innerHTML= result;
  }
  });
  }
}


  function genSession(){
  return '&r=' + Math.random(999);
  }

</script>

<!--[ include file="admin_header_menu.htm" ]-->
<div class="admin_content">

<a class="button" href="#"><!--[pnml name='_ICARRENT_ADMIN_FORM_PICKUPLOCATE']--> <!--[get_shop_by_id shop_id=$_GET.shop_id]--></a>
<form id='form' class='form' action="<!--[pnmodurl modname='iCarrent' type='adminform' func='submit' ctrl='pickuplocation']-->" method="post">
<input type="hidden" name="form[id]" value="<!--[$_GET.id]-->" />
<!--[if !$form.shop_id]-->
  <input type="hidden" name="form[shop_id]" value="<!--[$_GET.shop_id]-->" />
  <input type="hidden" name="forward[shop_id]" value="<!--[$_GET.shop_id]-->" />
<!--[else]-->
  <input type="hidden" name="form[shop_id]" value="<!--[$form.shop_id]-->" />
  <input type="hidden" name="forward[shop_id]" value="<!--[$form.shop_id]-->" />
<!--[/if]-->
<input type="hidden" name="forward[func]" value="list" />
<input type="hidden" name="forward[ctrl]" value="pickuplocation" />

<table class="adminform">
  <tr>
    <td class='td-label'><label><!--[pnml name='_ICARRENT_ADMIN_FORM_PICKUPLOCATE_PROVINCE']--> : </label></td>
    <td class='td-data'>
            <!--[selector_object_array_ex modname="iCarrent"
                    class="Province"
                    field="id"
                    displayField="name"
                    name="form[province_id]"
                    selectedValue=$form.province_id
                    onChange="getDistrict(this)"
            ]-->
    </td>
  </tr>
  <tr>
    <td class='td-label'><label><!--[pnml name='อำเภอ/เขต']--> : </label></td>
    <td class='td-data'>
        <div id='district_container'>
          <!--[assign var='province_id' value=$form.province_id]-->
          <!--[if not empty($province_id)]-->
            <!--[selector_object_array_ex modname="iCarrent"
              class="District"
              field="id"
              defaultValue="0"
              displayField="name"
              name="form[district_id]"
              selectedValue=$form.district_id
              size="6"
              where="dis_prov_id = '$province_id'"
            ]-->
          <!--[else]-->
            <FONT size='2'>กรุณาเลือกจังหวัด....</FONT>
          <!--[/if]-->
        </div>
    </td>
  </tr>
  <tr>
    <td class='td-label'><!--[pnml name='_ICARRENT_ADMIN_FORM_PICKUPLOCATE_NAME']--> : </td>
    <td class='td-data'><input type="text" name="form[name]" value="<!--[$form.name]-->" title="Please enter category name" class="required"  /></td>
  </tr>
</table>

<!--  <fieldset>
    <legend><a href="#" onclick="Effect.toggle('advert_map', 'slide'); return false;"><img align="absmiddle" src="modules/iCarrent/pnimages/001_03.gif"  /><!--[pnml name='แผนที่ / ที่ตั้งของร้าน']-->  </a></legend>
    <div align="center" id="advert_map">
      <TABLE  width="90%" border="0" class="table-label">
      <TR>
        <TD class='td-label'><!--[pnml name='latitude']--> : </TD>
        <TD class='td-data'><input name   ="form[latitude]"
                                   id     ="form[latitude]"
                                   type   ="text"
                                   size   ="20"
                                   value  ="<!--[$form.latitude]-->" /></TD>
      </TR>
      <TR>
        <TD class='td-label'><!--[pnml name='longtitude']--> : </TD>
        <TD class='td-data'><input name   ="form[longitude]"
                                   id     ="form[longitude]"
                                   type   ="text"
                                   size   ="20"
                                   value  ="<!--[$form.longitude]-->" /></TD>
      </TR>
      <TR>
        <td colspan="2"><div id='map' style="width:100%; height:400px;"></div></td>
      </TR>
      </TABLE>
    </div>
 </fieldset> -->

	<button name="button_submit" value='Submit' type="submit" class="button save">ตกลง</button>
	<button name="button_cancel" value='Cancel' type="submit" class="button flag">ยกเลิก</button>
</form>
</div>